import datetime
import json
import os

import requests

data = requests.post('http://127.0.0.1:5000/course/blogin', {'username': 'zs', 'password': '123'})
res = json.loads(data.text)

file = "不通过"
if res['code'] == 200:
    file = "通过"

dict1 = {"url": "http://127.0.0.1:5000/course/blogin", "请求方式": "POST", "测试结果": file}

filename = datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d")
with open(os.path.join(filename + '.txt'), 'w', encoding='utf8')as f:
    f.write(json.dumps(dict1, ensure_ascii=False))
